class User < ActiveRecord::Base
	has_many :frees
	belongs_to :event
	
	validates_numericality_of :event_id
	validates_presence_of :name
	#validates_presence_of :login
	#validates_presence_of :password
	#validates_presence_of :email
	#validates_confirmation_of :email
	#validates_uniqueness_of :login
	#validates_uniqueness_of :email
	
	
	def self.authenticate(login, password)
		find(:first, :conditions => ["login = ? and password = ?", login, Digest::SHA1.hexdigest(password)])
	end
	
	def password=(value)
		write_attribute("password", Digest::SHA1.hexdigest(value))
	end		
	
end
